/**
 * 定义站点信息管理模块
 */
(function(window, angular, undefined){
	var Module = angular.module('water.apps.ws.wsclcManager.wsclcInfo.monitorStationManager', ['water.entity.monitorStation',
	                                                                                          'water.apps.common.stationInfo.monitorStationManager']);
	
	Module.controller('stationManagerController',function($rootScope,$scope,$monitorStationService,$controller){
		/**
		 * 选择的污水处理厂id
		 */
		$scope.WWTPID;
		var control = $controller("commonStationManagerController",{$scope:$scope});
		$scope.dataPramChangedBroadCast();
		/**
		 * 监听站点列表点击事件
		 */
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			if($wdp.viewValue.wwtpDetailParm.WWTPID){
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope._getStationsList($scope.WWTPID);
			}
        },true);
		/**
		 * 提交编辑按钮点击事件
		 */
		$scope.onSubmitEditClick = function(data){
			$monitorStationService.updateModel(data).then(function(){
				$.messager.alert("保存成功","保存成功",'info');
				$scope._getStationsList($scope.WWTPID);
				$scope.editDialog.close();
			});
		}
		/**
		 * 获取站点列表
		 */
		$scope._getStationsList= function(WWTPID){
			$monitorStationService.getList({'WWTP_ID':WWTPID}).then(function(d){
				$scope.stations = d
			});
		}
	});
}(window, angular));	